Skip to content

arch/mps: move the kernel heap to g_idle_topstack - #22730

Open
anjiahao1 wants to merge 1 commit into
apache:masterfrom
anjiahao1:20261202_mps-kheap
Open

anjiahao1 wants to merge 1 commit into
apache:masterfrom
anjiahao1:20261202_mps-kheap

Conversation

@anjiahao1

Copy link
Copy Markdown
Contributor

Summary

Anchor the kernel heap at g_idle_topstack and reserve
CONFIG_MM_KERNEL_HEAPSIZE right after it, instead of placing the heap at
the top of the primary RAM. The user heap then starts past the reserved
region.

This keeps the kernel heap in RAM the kernel already owns rather than
reaching to the top of the region, matching the layout used by other
architectures with a dedicated kernel heap.

Impact

arch/arm/src/mps/mps_allocateheap.c only. Protected builds take the
USERSPACE path and are unchanged; flat builds with
CONFIG_MM_KERNEL_HEAP=y now get the kernel heap directly after the idle
stack and a user heap shifted by the reserved size.

Testing

  • tools/checkpatch.sh -c -u -m passes.
  • tools/configure.sh mps3-an547:nsh with CONFIG_MM_KERNEL_HEAP=y
    builds successfully, which compiles both changed branches.

Anchor the kernel heap at g_idle_topstack and reserve
CONFIG_MM_KERNEL_HEAPSIZE right after it, instead of placing the heap at
the top of the primary RAM.  The user heap then starts past the reserved
region.

This keeps the kernel heap in the RAM that the kernel already owns
instead of reaching to the top of the region, which is the layout used
by other architectures that support a dedicated kernel heap.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
@anjiahao1
anjiahao1 requested a review from jerpelea as a code owner December 2, 2026 11:28
@jerpelea jerpelea changed the title mps: move the kernel heap to g_idle_topstack arch/mps: move the kernel heap to g_idle_topstack Dec 2, 2026

@jerpelea jerpelea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename the commit title to
arch/mps: move the kernel heap to g_idle_topstack

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants